package ldk.learning.jni;

import java.nio.file.FileSystems;
import java.nio.file.Path;

public class JNIHelper {

    static {
        Path workingPath = FileSystems.getDefault().getPath("lib/");
        String workingDirPath = workingPath.toAbsolutePath().toString();
        System.load(workingDirPath + "/" +libraryFileName("native-lib"));
    }

    public static String libraryFileName(String fileName){
        String osName = System.getProperty("os.name");
        if (osName.startsWith("Linux")){
            return "lib" + fileName + ".so";
        }else if (osName.startsWith("Mac")){
            return "lib" + fileName + ".dylib";
        }else{
            return "lib" + fileName + ".dll";
        }
    }

    public native String stringFromJNI();
    public native void testStringFunction();
    public native void testStructureFunction();
    public native void testMemoryFunction();
    public native void testFieldsFunction();
}
